package com.taxicalculator.dao;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
/**
 * 
 * @author Thomas Maco
 *
 */
public class NetworkDAO implements INetworkDAO {
	/**
	 * go to URI and gets JSON Results
	 * @param uri to direct to 
	 */
	public String request(String uri) throws ClientProtocolException, Exception {
		
			String result = "";
			
			// request
			HttpGet httpGet = new HttpGet(uri);

			// handles the response.
			ResponseHandler<String> handler = new BasicResponseHandler();
			
			// join these together.
			HttpClient httpClient = new DefaultHttpClient();
			
			// create a network connection.  Get a result.
			result = httpClient.execute(httpGet, handler);
			
			// return that result.
			return result;
		
	}

}
